<?php
/**
 * Model for app info
 *
 * @category Abovo
 * 
 * @package Abovo_Model_Apps
 * 
 * @author Antti Holvikari <anttih@gmail.com>
 * 
 * @license http://opensource.org/licenses/gpl-license.php GPL
 */

/**
 * Model for app info
 *
 * @category Abovo
 * 
 * @package Abovo_Model_Apps
 * 
 * @author Antti Holvikari <anttih@gmail.com>
 */
class Abovo_Model_Apps extends Abovo_Sql_Table {
    
    /**
     * 
     * Fetch list of apps and their info
     * 
     * @return array
     * 
     */
    public function fetchAllApps()
    {
        $sel = Solar::factory('Solar_Sql_Select');
        return $sel->from($this->_name, 'name')->order('name')->fetch('col');
    }
    
    /**
     * Set up table schema and indices
     *
     * @return void
     */
    protected function _setup()
    {
        $this->_name = 'apps';
        
        $this->_col['id'] = array(
            'type'    => 'int',
            'primary' => true,
            'autoinc' => true,
            'require' => true,
        );
        
        $this->_col['name'] = array(
            'type'  => 'varchar',
            'size'  => 100,
        );
        
        // Make sure sql is available
        if (! Solar::isRegistered('sql')) {
            Solar::register('sql', Solar::factory('Solar_Sql'));
        }
    }
}

